<script type="text/javascript">

//Change class name: 

function ChangeClass(sid,sclassname) { 

   document.getElementById(sid).className = sclassname; 

} 

</script>        

<em class="count">

    <strong>

        <?php if ($this->comment_count == 0): ?>

            Chưa có bình luận nào

        <?php else: ?>        

            Có <?= $this->comment_count ?> bình luận

        <?php endif; ?>

    </strong>

</em>

<div class="clear"></div>

<?

for ($i=0; $i<count($this->comments); $i++)

{

    $c=$this->comments[$i];

?>

<div class="inputMess02">

    <div class="float-left">

        <?php if ($c->avatar != ''): ?>

            <a href="/home/<?= $c->uname ?>"><img src="http://img.tamtay.vn/<?= $c->avatar ?>" width="60"/></a>    

        <?php else: ?>

            <a href="/home/<?= $c->uname ?>"><img src="http://img.tamtay.vn/themes/tt2_home_themes/images/nophoto.gif" width="60" /></a>    

        <?php endif; ?>

    </div>

    <div class="text"> 

        <span class="display-block">

            <a href="/home/<?= $c->uname ?>" class="bold"><?= $c->uname ?></a>

            :  <?= $this->smilleyParser($c->content) ?>

        </span> 

        <span class="inputTime">(<?= date("H:i:s d/m/y", $c->created) ?>)</span>

        

    </div>    

    <div class="float-right">        

    

    <?php if ($this->isEventAdmin): ?>

        <a href="#"  onclick="return event_comment.deleteComment('<?= $c->cid ?>')"><img src="/images/icons/spacer.gif" onmouseout="javascript:ChangeClass('btn_close_<?= $c->cid ?>','btn_close')" onmouseover="javascript:ChangeClass('btn_close_<?= $c->cid ?>','btn_close_hover')" alt="Xóa comment này" id="btn_close_<?= $c->cid ?>" class="btn_close"/></a>           

    <?php endif; ?>

    <?php if ($this->user->uid > 0): ?>

        <a href="#" onclick="return event_comment.showReplyBox(<?= $c->cid ?>)"><img src="/images/reply.png" class="display-block" width="16" height="16" style="margin-top:5px;"/></a>        

    <?php endif; ?>

    <!--

    <a href="#"><img src="/images/icons/spacer.gif" onmouseout="javascript:ChangeClass('btn_close','btn_close')" onmouseover="javascript:ChangeClass('btn_close','btn_close_hover')" alt="Đăng nhạc" id="btn_close" class="btn_close"/></a>

    <a href="#"><img src="/images/reply.png" class="display-block" width="16" height="16" style="margin-top:5px;"/></a>

    -->

    </div>    

    <div class="clear"></div>

</div>

<div class="commentWrap-lv2">        

    <?php if (isset($this->replies[$c->cid])): ?>

        <?php 

            $replies = $this->replies[$c->cid];

            $numOfReplies = count($replies);

        ?>

        <?php if ($numOfReplies > 2): ?>  

        <div class="inputMess05" id="display_reply_<?= $c->cid ?>">

            <a href="#" onclick="return event_comment.showReply(<?= $c->cid ?>)" >Hiển thị tất cả <?= $numOfReplies ?> trả lời...</a>

        </div>

        <?php endif; ?>

        <?php for ($j = 0; $j < $numOfReplies; $j++): ?>

        <?php                     

            $reply = $replies[$j];                      

            if ($j < ($numOfReplies - 2)) {

                $style = 'display:none;'; 

            } else {

                $style = '';

            }

        ?>

        <div class="inputMess03 reply_comment_<?= $c->cid ?>" style="<?= $style ?>">

            <div class="float-left relative">

                <?php if ($reply->avatar != ''): ?>

                    <a href="/home/<?= $reply->uname ?>"><img src="http://img.tamtay.vn/<?= $reply->avatar ?>" width="40"/></a>    

                <?php else: ?>

                    <a href="/home/<?= $reply->uname ?>"><img src="http://img.tamtay.vn/themes/tt2_home_themes/images/nophoto.gif" width="40" /></a>    

                <?php endif; ?>

            </div>

            <?php if ($this->isEventAdmin): ?>

                <div class="float-right relative">

                    <a href="#" onclick="return event_comment.deleteComment('<?= $reply->cid ?>')"><img src="/images/icons/spacer.gif" onmouseout="javascript:ChangeClass('btn_close_<?= $reply->cid ?>','btn_close')" onmouseover="javascript:ChangeClass('btn_close_<?= $reply->cid ?>','btn_close_hover')" alt="Xóa comment này" id="btn_close_<?= $reply->cid ?>" class="btn_close"/></a>

                </div>

            <?php endif; ?>

            <span class="text" style="width: 155px;"> <a href="/home/<?= $reply->uname ?>" class="bold"><?= $reply->uname ?></a>: <?= $this->smilleyParser($reply->content) ?> <span class="inputTime">(<?= date("H:i:s d/m/y", $reply->created) ?>)</span> </span>

            <div class="clear"></div>

        </div>

        <?php endfor; ?>

        <?php if (count($this->replies[$c->cid]) > 0): ?>

            <?php if ($this->user->uid > 0): ?>

            <div class="inputMess05" id="reply_hint_<?= $c->cid ?>">

                <input name="" type="text" class="inputText" value="Viết bình luận của bạn..." onclick="event_comment.showReplyBox(<?= $c->cid ?>)"/>

            </div>

            <?php endif; ?>

        <?php endif; ?>

    <?php endif; ?>

    
    <?php
    if($this->user->uid > 0){
?>
    <div class="inputMess04" id="reply_box_<?= $c->cid ?>" style="display: none;">

        <div class="float-left relative">

             <?php if ($this->user->picture != ''): ?>

                <a href="/home/<?= $this->user->name ?>"><img src="http://img.tamtay.vn/<?= $this->user->picture ?>" width="40"/></a>    

            <?php else: ?>

                <a href="/home/<?= $this->user->name ?>"><img src="http://img.tamtay.vn/themes/tt2_home_themes/images/nophoto.gif" width="40" /></a>    

            <?php endif; ?>

        </div>

        <div class="text02">

            <fieldset style="border: 0px; padding: 0px;">

                <div>

                    <textarea id="comment_content_<?= $c->cid ?>" name="comment_content"></textarea>

                </div>

            </fieldset> 

            <input name="" type="button" value="Gửi" class="button float-left" onclick="event_comment.saveComment(<?= $this->event->eid?>, <?= $c->cid ?>)" />

            <div class="clear"></div>

        </div>

        <div class="clear"></div>

    </div>
    <?php
    }
?>      

</div>

<?

}

?>         

<?

if ($this->first_level_comment_count>0)

{

    $page_count=ceil($this->first_level_comment_count/EVENT_COMMENT_PER_PAGE);

    $from=$this->current_page-3;

    if ($from<0)

    {

        $from=0;

    }

    $to=$this->current_page+3;

    if ($to>$page_count)

    {

        $to=$page_count;

    }   

         

    echo '<div class="pageView text-right">';

    if ($from>0)

    {

        echo '<a href="#" onclick="return event_comment.loadComment(' . $this->event->eid . ',0)">|&lt;</a>&nbsp;';

        echo '<a href="#" onclick="return event_comment.loadComment(' . $this->event->eid . ',' . ($i-1) . ')">&lt;&lt;</a>&nbsp;';

        echo '&nbsp;...&nbsp;';

    }

    for ($i=$from; $i<$to; $i++)

    {

        if ($i==$this->current_page)

        {

            echo '<span class="itemS">' . ($i+1) . '</span>&nbsp;';

        }

        else

        {

            echo '<a href="#" onclick="return event_comment.loadComment(' . $this->event->eid . ',' . $i . ')">' . ($i+1) . '</a>&nbsp;';

        }

    }

    if ($to<$page_count-1)

    {

        echo '&nbsp;...&nbsp;';

        echo '<a href="#" onclick="return event_comment.loadComment(' . $this->event->eid . ',' . ($this->current_page+1) . ')">&gt;&gt;</a>&nbsp;';

        echo '<a href="#" onclick="return event_comment.loadComment(' . $this->event->eid . ',' . ($page_count-1) . ')">&gt;|</a>&nbsp;';

    }

    echo '<div class="clear"></div></div>';

}

?>



 